package com.example.administrator.stargo.utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.example.administrator.stargo.R;


/**
 * Created by Mloong on 2017/12/15.   倒计时
 */

public class MyCountDownTimer extends CountDownTimer{

    TextView textView;
    Context context;
    long millisInFuture;
    long countDownInterval;

    public MyCountDownTimer(Context context,long millisInFuture, long countDownInterval,TextView textView) {
        super(millisInFuture, countDownInterval);
        this.context = context;
        this.textView = textView;
        this.millisInFuture = millisInFuture;
        this.countDownInterval = countDownInterval;
    }

    @Override
    public void onTick(long millisInFuture) {
        textView.setClickable(false);
        textView.setText(millisInFuture/1000 + "s");
        textView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.banyuan_code_jishi));
    }

    @Override
    public void onFinish() {
        textView.setText("重新获取验证码");
        textView.setClickable(true);
        textView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.banyuan_code));
    }
}
